# -*- coding: utf-8 -*-
"""
Created on Thu Nov 17 21:23:43 2022

@author: YSL
"""

matrix=[[1, 4, 7, 11, 15],
[2, 5, 8, 12, 19],
[3, 6, 9, 16, 22],
[10, 13, 14, 17, 24],
[18, 21, 23, 26, 30]]

print(matrix[:][:])

target=input("请输入搜寻值")
num = int(target)
m=5 #行
n=5 #列

if (num>=matrix[0][0] and num<=matrix[m-1][n-1]):
    for i in range(m):
        for j in range(n):
            if num<matrix[i][j]:
                j-=1
                break
        if num==matrix[i][j]:
            print("True")
            print("定位在matrix[%d][%d]" % (i+1,j+1))
            break
    if num>matrix[m-1][j]:
      print("false")  
else:
    print("false")

#%%

matrix=[[1, 4, 7, 11, 15],
[2, 5, 8, 12, 19],
[3, 6, 9, 16, 22],
[10, 13, 14, 17, 24],
[18, 21, 23, 26, 30]]

print(matrix[:][:])

target=input("请输入搜寻值")
num = int(target)
m=5 #行
n=5 #列

if (num>=matrix[0][0] and num<=matrix[m-1][n-1]):
    for i in range(n):
        for j in range(m):
            if num<matrix[j][i]:
                j-=1
                break
        if num==matrix[j][i]:
            print("True")
            print("定位在matrix[%d][%d]" % (j+1,i+1))
            break
    if num>matrix[j][n-1]:
      print("false")  
else:
    print("false")